package cn.conchit.apccontroldemo.graph.cross;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Objects;

/**
 * @author hetao
 * @version 1.0
 * @description: TODO
 * @date 2023/2/14 16:04
 */

@Data
@AllArgsConstructor
public class GraphNode<V> {

    /** 
     * @description: 节点索引，通过索引去查找，节点在有向图数组中的位置
     */ 
    private int index;
    private V vertex;
    private Edge firstIn;
    private Edge firstOut;

    public GraphNode(V v, int index) {
        this.vertex = v;
        this.index = index;
        this.firstIn = null;
        this.firstOut = null;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        GraphNode<?> that = (GraphNode<?>) o;
        return vertex.equals(that.vertex);
    }



    @Override
    public int hashCode() {
        return Objects.hash(vertex);
    }
}
